/****************************************************************************

 Copyright (C) 2002-2007 Gilles Debunne (Gilles.Debunne@imag.fr)

 This file is part of the QGLViewer library.
 Version 2.3.0, released on June 29, 2008.

 http://artis.imag.fr/Members/Gilles.Debunne/QGLViewer

 libQGLViewer is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 2 of the License, or
 (at your option) any later version.

 libQGLViewer is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with libQGLViewer; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

*****************************************************************************/

#include "simpleViewer.h"
#include <qapplication.h>

int main(int argc, char** argv)
{
  // Read command lines arguments.
  QApplication application(argc,argv);

  // Instantiate the viewer.
  Viewer viewer;

#if QT_VERSION < 0x040000
  // Set the viewer as the application main widget.
  application.setMainWidget(&viewer);
#else
  //viewer.setWindowTitle("simpleViewer");
#endif

    cout << "load tet" << endl;
    TetgenParser parser(argv[1]);
	Mesh testMesh = parser.load();
    cout << "load done" << endl;

	vector<Vector3> nodes;
	vector<Face_t> faces;

	testMesh.getBoundary(nodes, faces);
	map<unsigned int, unsigned int>& nodesMapBToV = testMesh.nodesMapBToV;


    Material m;
    m.R = 255.0;
    m.G = 255.0;
    viewer.addMaterial(m, "duckMaterial");

	viewer.addMesh(testMesh, "testMesh");
	//viewer.createEntity("test", "testMesh", "dummyMat");
	//viewer.linkEntityToRoot("test");

	SceneNode& child = viewer.getRoot().createChild();
	viewer.createEntity("duck", "testMesh", "duckMaterial");
    child.linkEntity("duck");


  // Make the viewer window visible on screen.
  viewer.show();

  // Run main loop.
  return application.exec();
}
